{% load i18n %}

<div class="inline-group inline-stacked{% if inline_admin_formset.opts.sortable %} sortable{% endif %}{% if inline_admin_formset.opts.classes %} {{ inline_admin_formset.opts.classes|join:" " }}{% endif %}"
     name="inlinegroup">
    <h2>{{ inline_admin_formset.opts.verbose_name_plural|title }}</h2>
    <ul class="inline-item-tools">
        <li><a href="javascript://" class="openhandler" title="{% trans 'Open All Items' %}"></a></li>
        <li><a href="javascript://" class="closehandler" title="{% trans 'Close All Items' %}"></a></li>
        {% if inline_admin_formset.opts.allow_add %}
            <li><a href="javascript://" class="addhandler" title="{% trans 'Add Item' %}"></a></li>{% endif %}
    </ul>
    {{ inline_admin_formset.formset.management_form }}
    {{ inline_admin_formset.formset.non_form_errors }}
    <div class="items"> <!-- sortable container -->
        {% for inline_admin_form in inline_admin_formset %}
            <div class="inline-related collapse-closed{% if inline_admin_form.original or inline_admin_form.show_url %} has_original{% endif %}">
                <!-- sortable items -->
                <!-- headline, original, delete/link/sort -->
                <h3 style="display: none;">
                    {% for fieldset in inline_admin_form %}
                        {% for line in fieldset %}
                            {% for field in line %}
                                {% if field.field.name == "_order" %} {{ field.field }} &nbsp; {% endif %}
                            {% endfor %}
                        {% endfor %}
                    {% endfor %}
                    <b>{{ inline_admin_formset.opts.verbose_name|title }}
                        #{{ forloop.counter }}</b>&nbsp;&nbsp;{% if inline_admin_form.original %}
                    {{ inline_admin_form.original }}{% endif %}
                </h3>
                <ul class="inline-item-tools">
                    {% if inline_admin_form.show_url %}
                        <li>
                            <a href="../../../r/{{ inline_admin_form.original.content_type_id }}/{{ inline_admin_form.original.id }}/"
                               class="viewsitelink" title="{% trans 'View on Site' %}" target="_blank"></a>
                        </li>{% else %}
                        <li>&nbsp;</li>{% endif %}
                    {% if inline_admin_formset.opts.sortable %}
                        <li><a href="javascript://" class="draghandler" title="Move Item"></a></li>{% else %}
                        <li>&nbsp;</li>{% endif %}
                    {% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}
                        <li>{{ inline_admin_form.deletion_field.field }}<a href="javascript://" class="deletelink"
                                                                           title="{% trans 'Delete Item' %}"></a>
                        </li>{% else %}
                        <li>&nbsp;</li>{% endif %}
                </ul>
                <!-- fieldsets -->
                {% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %}
                {% for fieldset in inline_admin_form %}
                    {% include "admin/includes/fieldset_inline.html" %}
                {% endfor %}
                {{ inline_admin_form.pk_field.field }}
                {{ inline_admin_form.fk_field.field }}
            </div>
        {% endfor %}
        {{ inline_admin_formset.extra_forms }}
    </div>
</div>

<div class="sortablehelper">
    <h3><b>Sortable Helper</b></h3>
</div>
